package org.misty.blog.controller;

import org.misty.blog.service.ArticleService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class ArchivesViewController {
    private final ArticleService articleService;

    public ArchivesViewController(ArticleService articleService) {
        this.articleService = articleService;
    }

    @GetMapping("/archives")
    public String archives(Model model) {
        model.addAttribute("articleCount", articleService.countArticle());
        model.addAttribute("archiveMap", articleService.archiveArticles());
        return "archives";
    }
}
